<?php
/*
 * 接口：/receive_record/add
 * 说明：更新领用记录
 */
//关闭事物自动提交
$db->mysqlDB->falseAutoCommit();

//获取请求参数
$params = $route->bodyParams;

//更新领用记录信息
$P1 = array(
  "update_where" => 'orr_id',
  "orr_id" => $params['orr_id'],
  "orr_number" => $params['orr_number'],
  "orr_note" => $params['orr_note'],
  "orr_is_type" => $params['orr_is_type'],
  "orr_uid" => $params['orr_uid']
);
$R1 = $db->mysqlDB->automaticUpdate($P1)->update("easyd_oa_receive_record");

//计算剩余库存
$inventory = $params['inventory'] + $params['old_orr_number'] - $params['orr_number'];

//更新库存信息
$P2 = array(
  "update_where" => 'oos_id',
  "oos_id" => $params['orr_oosid'],
  "oos_number" => $inventory
);

$R2 = $db->mysqlDB->automaticUpdate($P2)->update("easyd_oa_office_supplies");

if(!$R1||!$R2){
  $db->mysqlDB->rollBackCommint();
  $db->mysqlDB->trueAutoCommit();
  $response->responseData(false);
}else{
  $db->mysqlDB->actionCommint();
  $db->mysqlDB->trueAutoCommit();
  $response->responseData(true);
}
?>